|
|
|
|
|
|
|
Chapter 14 included a brief overview of Property Pages, which are tabbed dialog boxes designed to make it easy for users to set design-time properties. As you know, Property Pages can be displayed by pressing the ellipsis button in the Custom property of the Properties window, or by right-clicking a control and choosing Properties. In addition to being a neat way to organize the properties of your control, Property Pages included with your control can be used in a development environment other than Visual Basic. |
|
|
|
|
|
|
|
|
Chapter 14 showed how to create Property Pages by using the Property Pages Wizard. The wizard is designed to provide you with a quick way of creating a property sheet, but it does not provide all the possible options. In this section, you learn how to create Property Pages manually, which allows you to make design and feature choices that are unavailable through the Property Pages Wizard. |
|
|
|
|
|
|
|
|
See "Using the Property Pages Wizard," p. 330 |
|
|
|
|
|
|
|
|
The following list describes the general steps involved in creating Property Pages, and the subsequent sections explain these steps in more detail: |
|
|
|
|
|
|
|
|
1. Create Property Page objects for each group of properties. |
|
|
|
|
|
|
|
|
2. On the Property Page objects, place controls that the developer can use to edit the properties. |
|
|
|
|
|
|
|
|
3. Implement the SelectionChanged event procedure for each Property Page. This event procedure is responsible for reading in the current values of each control's properties. |
|
|
|
|
|
|
|
|
4. Implement the Change event procedure (or sometimes the Click event procedure) for each control on each Property Page. |
|
|
|
|
|
|
|
|
5. Implement the ApplyChanges event procedure for each Property Page. Its task is to copy the new property values from the Property Page controls to the corresponding properties on the user control. |
|
|
|
|
|
|
|
|
6. Connect the Property Pages to the custom control. |
|
|
|
|
|
|
|
|
Creating Property Page Objects |
|
|
|
|
|
|
|
|
The first step in creating the Property Pages dialog box for your control is to create Property Page objects for each group of properties you want to include. How you organize these groups is entirely up to you, although you should use common sense. If your control has only a few properties, you may need only a single Property Page. However, if the control has many properties, you should group related properties on their own Property Pages. |
|
|
|
|
|
|
|
|
For the sample Calculator control, you'll create only a single Property Page called General. Follow these steps to add the General Property Page object to the user control project: |
|
|
|
|
|
|
|
|
1. Make sure that ActiveX Control project is selected in the Project Explorer and choose Project, Add Property Page. The Add PropertyPage dialog box appears. |
|
|
|
|
|